#!/bin/bash
#

# setup
binary=$1
tmp_file=stdout.tmp

# start timing
t_start=`date +%s`

# run binary
$binary >$tmp_file

# stop timing
t_stop=`date +%s`

# calculate runtime
runtime=$(expr $t_stop - $t_start)
if [ "$runtime" = "0" ]; then
    runtime="1"
fi

# check verification
status="pass"
check=`grep "SUCCESSFUL" $tmp_file`
if [ -z "$check" ]; then
    status="fail"
fi

# retrieve error
err=`grep "ERROR:" $tmp_file`
echo "error:   ${err//  ERROR:   /}"

# print output
echo "status:  $status"
echo "time:    $runtime"

# cleanup
rm -f $tmp_file


